<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>登录-{$siteInfo['title']}</title>
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta name="description" content="{$siteInfo['description']}">
    <meta name="keywords" content="{$siteInfo['keyword']}">
    <meta name="author" content="Teen">
    <link rel="stylesheet" href="/themes/default/static/element-ui-2.12/index.css">
    <link rel="stylesheet" href="/themes/default/static/css/common.css" />
    <link rel="stylesheet" href="/themes/default/static/css/home.css" />
    <link rel="stylesheet" href="/themes/default/static/css/login.css" />
</head>
<body>
<div id="app">
    {include file="common/header" /}
    <div class="with1200">
    <div class="login-right">
        <h2> <i id="wxIcon" class="layui-icon layui-icon-login-wechat"></i>&nbsp;微信扫码登录</h2>
        <img id="wxCode" src="">
        <div id="mask" class="mask">
            <p class="colorRed">二维码已失效</p>
            <p style="cursor:pointer;" onclick="refreshCode()"><i class="layui-icon layui-icon-refresh"></i>刷新</p>
        </div>
        <ul>
            <li><a href="/home/member/login">账号登录</a></li>
            <li><a href="#">QQ登录</a></li>
            <li><a href="/home/member/register">注册</a></li>
        </ul>
    </div>
    </div>
</div>
</body>
<script src="https://cdn.bootcss.com/vue/2.6.10/vue.min.js"></script>
<script src="/themes/default/static/element-ui-2.12/index.js"></script>
<script type="text/javascript" src="/themes/default/static/js/jquery-3.2.1.min.js" ></script>
<script type="text/javascript" src="/themes/default/static/js/home.js" ></script>
<script>
    new Vue({
        el: '#app'
    })
    reqCode();
    function refreshCode() {
        $("#mask").hide();
        $(".login-right ul").show();
        reqCode();

    }
    function reqCode(){
        $.ajax({
            type:"POST",
            url:"/home/wechat/reqCode",
            success(e){
                $("#wxCode").attr("src",e.url);
                setTimeout(function () {
                    $("#mask").show();
                    $(".login-right ul").hide();
                },30000)
            }
        });
    }

    var checkReqCode = setInterval(function(){
        $.ajax({
            type:"POST",
            url:"/home/wechat/checkSessionKey",
            success(e){
                if (e.code == 1){
                    clearInterval(checkReqCode);
                    $.ajax({
                        type:"POST",
                        url:"/home/wechat/createSession?sessionKey="+e.data,
                        success(e){
                            if (e.code == 1){
                                location.href = "/";
                            }
                        }
                    });
                }
            }
        });
    }, 2000);
</script>
</html>